
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <codecvt>
using namespace std;

int main(int argc, char const *argv[])
{
    auto lco_with_utf8 = std::locale(std::locale(""), new codecvt_utf8<wchar_t>);
    std::wfstream of("utf8.txt", ios::out|ios::binary);
    of << L"你好世界" << endl;

    of.imbue(lco_with_utf8);
    string str{"你好世界"};
    of << L"你好世界" << endl;
    of.close();
    return 0;
}
